﻿
Imports Microsoft.Office.Interop.Outlook

Namespace UI
    Public MustInherit Class pmBaseFolderTreeMailForm
        Inherits PMOutlookAddIn.UI.pmBaseFolderTreeForm

        Protected ReadOnly _mailToWorkWith As MailItem

        Friend Sub New(ByVal App As Application, ByVal mailToWorkWith As MailItem)
            MyBase.New(App)

            If IsNothing(mailToWorkWith) Then
                Throw New ArgumentNullException("mailToWorkWith")
            End If
            _mailToWorkWith = mailToWorkWith

            InitializeComponent()
        End Sub


        Private Sub btnNewFolder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNewFolder.Click
            Try
                Dim strResult As String = String.Empty

                Dim _pmNewFolderForm As New pmNewFolderForm(Me._app, _pmFoldertree.GetSelectedFolder, getSearchString, getEmail)
                If _pmNewFolderForm.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then

                    initializeTreeview()
                    SelectFolder(_pmNewFolderForm._newFolder)
                    _pmNewFolderForm.Dispose()
                End If

                'Using _pmNewFolderForm As pmNewFolderForm = New pmNewFolderForm(Me._app)
                '    _pmNewFolderForm.ShowDialog()
                'End Using
            Catch ex As System.Exception
                ExceptionHandler.ShowAndLog("Fout bij openen van NewFolderForm", ex)
            End Try
        End Sub

        Public MustOverride Function getEmail() As String
        Public MustOverride Function getSearchString() As String
         
        Private Sub pmBaseFolderTreeMailForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            SelectRelevantFolder(getSearchString)
        End Sub
    End Class
End Namespace